#ifndef __THREAD_H__
#define __THREAD_H__

#include "NoCopy.hpp"

#include <pthread.h>

#include <functional>

using std::function;

namespace cdm{

using ThreadCallback = function<void()>;

class Thread:public NoCopy{

public:
    Thread(ThreadCallback &&cb);
    virtual ~Thread();

    void start();
    void join();

private:
    static void* start_routine(void*);
    /* virtual void run() = 0;//基于对象，不需要纯虚函数重写 */

private:
    pthread_t       _thdId;
    bool            _isRunning;
    ThreadCallback  _cb;//基于对象，直接存回调函数
};

}

#endif


